import { request } from "@/request";
//新增物资分区
export const addZone = (params: API.addZone) =>
  request({
    method: "POST",
    url: "/materialZone/add",
    data: params,
  });

//删除分区
export const deleteZone = (id: string) =>
  request({
    method: "DELETE",
    url: `/materialZone/del/${id}`,
  });

//获取用户在该家庭的分区列表
export const getZoneList = (familyId: string) =>
  request({
    method: "GET",
    url: `/materialZone/list/${familyId}`,
  });

//授权用户分区权限
export const addZonePermission = (params: API.zonePermission) =>
  request({
    method: "POST",
    url: "/materialZone/addPermission",
    data: params,
  });

//撤销授权用户分区权限
export const delPermission = (params: API.zonePermission) =>
  request({
    method: "POST",
    url: "/materialZone/delPermission",
    data: params,
  });

//获取分区详情
export const getZoneDetail = (id: string) =>
  request<API.ZoneDetail>({
    method: "GET",
    url: `/materialZone/detail/${id}`,
  });

/**
 * 根据分区ID获取该分区有权限的用户
 */
export const getZoneUserList = (zoneId: string) =>
  request<API.UserInfo[]>({
    method: "GET",
    url: `/materialZone/userList/${zoneId}`,
  });
